package base.util;
import org.apache.log4j.Logger;

import java.io.*;
public class FileUtil {
	private static final Logger log = Logger.getLogger(FileUtil.class);

	/**
	 * 一行一行读取文件，适合字符读取，若读取中文字符时会出现乱码
	 * @param path
	 * @return
	 * @throws Exception
	 */
	public static String readFile(String path) {
		StringBuffer valueBuf = new StringBuffer();
		FileReader fr = null;
		try {
			fr = new FileReader(path);
			BufferedReader br = new BufferedReader(fr);
			String line = null;
			while ((line = br.readLine()) != null) {
				valueBuf.append(new String(line.getBytes(), "UTF-8"));
			}
			br.close();
			fr.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return valueBuf.toString();
	}
}
